/* Global Styles and Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #a8e6cf 0%, #dcedc1 100%);
}

/* Main Container - Adapts to iframe or standalone */
#app-container {
    width: 100%;
    height: 450px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(135deg, #a8e6cf 0%, #dcedc1 100%);
}

/* If opened in new tab, use 90vh */
@media (min-height: 600px) {
    body:not(.iframe-mode) #app-container {
        height: 90vh;
    }
}

/* Tooltip for header - appears on hover over main area */
#header-tooltip {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #2d3436;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    text-align: center;
}

#app-container:hover #header-tooltip {
    opacity: 1;
}

/* Game Screen */
#game-screen {
    padding: 35px 15px 15px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Status Bar */
#status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 15px;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    font-weight: 600;
    color: #2d3436;
}

.status-label {
    color: #636e72;
}

#lives-display {
    display: flex;
    gap: 3px;
}

.heart {
    font-size: 18px;
    animation: heartbeat 1.5s ease-in-out infinite;
}

.heart.lost {
    opacity: 0.3;
    filter: grayscale(100%);
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#timer {
    font-weight: 700;
    color: #e74c3c;
    font-size: 16px;
}

/* Character Section */
#character-section {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.85);
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

#character-avatar {
    font-size: 40px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.speech-bubble {
    flex: 1;
    background: #fff;
    padding: 10px 15px;
    border-radius: 15px;
    position: relative;
    font-size: 13px;
    line-height: 1.4;
    color: #2d3436;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.speech-bubble::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-right: 10px solid #fff;
}

/* Scenario Panel */
#scenario-panel {
    background: rgba(255, 255, 255, 0.9);
    padding: 12px;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
    flex-shrink: 0;
}

#scenario-image {
    font-size: 50px;
    margin-bottom: 8px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

#scenario-text {
    font-size: 14px;
    font-weight: 600;
    color: #2d3436;
    line-height: 1.4;
}

/* Choices Container */
#choices-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
}

.choice-button {
    background: linear-gradient(135deg, #74b9ff 0%, #a29bfe 100%);
    border: none;
    padding: 12px 15px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    position: relative;
    overflow: hidden;
}

.choice-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.2);
    transition: left 0.3s;
}

.choice-button:hover::before {
    left: 100%;
}

.choice-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.25);
}

.choice-button:active {
    transform: translateY(0);
}

.choice-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.choice-text {
    flex: 1;
    line-height: 1.3;
}

.choice-button.correct {
    background: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
    animation: correctPulse 0.5s;
}

.choice-button.incorrect {
    background: linear-gradient(135deg, #ff7675 0%, #d63031 100%);
    animation: shake 0.5s;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Feedback Panel */
#feedback-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.2);
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #2d3436;
    animation: slideIn 0.3s;
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    z-index: 100;
}

@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.hidden {
    display: none !important;
}

/* Result Screen */
#result-screen {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#result-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 400px;
    animation: popIn 0.5s;
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

#badge-display {
    font-size: 80px;
    margin-bottom: 15px;
    animation: rotate 1s ease-in-out;
}

@keyframes rotate {
    from { transform: rotate(0deg) scale(0); }
    to { transform: rotate(360deg) scale(1); }
}

#result-title {
    font-size: 24px;
    color: #2d3436;
    margin-bottom: 10px;
}

#result-message {
    font-size: 14px;
    color: #636e72;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Game Over Screen */
#gameover-screen {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#gameover-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 400px;
    animation: popIn 0.5s;
}

.gameover-icon {
    font-size: 80px;
    margin-bottom: 15px;
    animation: heartBreak 1s;
}

@keyframes heartBreak {
    0% { transform: scale(1); }
    25% { transform: scale(1.2) rotate(-10deg); }
    50% { transform: scale(1.2) rotate(10deg); }
    75% { transform: scale(1.2) rotate(-10deg); }
    100% { transform: scale(1); }
}

#gameover-content h2 {
    font-size: 24px;
    color: #e74c3c;
    margin-bottom: 10px;
}

#gameover-content p {
    font-size: 14px;
    color: #636e72;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Action Buttons */
.action-button {
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
    width: 100%;
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.6);
}

.action-button:active {
    transform: translateY(0);
}

/* Audio Controls */
#audio-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1001;
}

.icon-button {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 12px rgba(0,0,0,0.25);
}

.icon-button:active {
    transform: scale(0.95);
}

/* Responsive adjustments for smaller screens */
@media (max-width: 480px) {
    #game-screen {
        padding: 30px 10px 10px;
        gap: 8px;
    }
    
    .status-item {
        font-size: 12px;
    }
    
    #character-avatar {
        font-size: 35px;
    }
    
    .speech-bubble {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    #scenario-image {
        font-size: 40px;
    }
    
    #scenario-text {
        font-size: 13px;
    }
    
    .choice-button {
        font-size: 12px;
        padding: 10px 12px;
        min-height: 45px;
    }
    
    .choice-icon {
        font-size: 20px;
    }
}

/* Scrollbar styling */
#choices-container::-webkit-scrollbar {
    width: 6px;
}

#choices-container::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
}

#choices-container::-webkit-scrollbar-thumb {
    background: rgba(108, 92, 231, 0.5);
    border-radius: 10px;
}

#choices-container::-webkit-scrollbar-thumb:hover {
    background: rgba(108, 92, 231, 0.7);
}